﻿
namespace Common.Algorithm.Display;
internal class ParticleSwarmDisplay
{
    public static void Display(ScottPlot.IPlotControl avaPlot1)
    {
        //  var records = NSGAIIBinaryExecute.Run();
        var records = ParticleSwarmExecute.Run();

        var plot = avaPlot1.Plot;
        var adder = avaPlot1.Plot.Add;

        //plot.AddScatter(records.Select(r => r[2]).ToArray(), records.Select(r => r[3]).ToArray());
        foreach (var record in records.GetRange(records.Count - 101, 100))
        {
            //plot.AddScatter(record[2], record[3]);
            adder.Scatter(record[0], record[1]);
        }
        //adder.Scatter(records.Last()[2], records.Last()[3]);
        //avaPlot1.Refresh();

        avaPlot1.Plot.XLabel("F1");
        avaPlot1.Plot.YLabel("F2");
        avaPlot1.Plot.Title("测试曲线");

        var axisManager = avaPlot1.Plot.Axes;
        axisManager.AutoScale();
        //avaPlot1.Plot.AxisAuto();
        avaPlot1.Refresh();

        //Thread.Sleep(1000);

        //_renderTimer = new DispatcherTimer
        //{
        //    Interval = TimeSpan.FromMilliseconds(1)
        //};
        //_renderTimer.Tick += Render;
        //_renderTimer.Start();

        //Closed += (sender, args) =>
        //{
        //    _updateDataTimer?.Dispose();
        //    _renderTimer?.Stop();
        //};
    }

}
